FROM ascendhub.huawei.com/public-ascendhub/mindspore-modelzoo:21.0.3

ENV DEBIAN_FRONTEND=nointeractive

RUN echo '[global] \n\
index-url=https://pypi.tuna.tsinghua.edu.cn/simple\n\
trusted-host=pypi.tuna.tsinghua.edu.cn' > ~/.pip/pip.conf

RUN pip install --upgrade pip && pip install label-studio==1.3post1 && \
    apt-get update && \
    apt-get install -y python3-opencv

RUN pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.6.0/MindSpore/cpu/x86_64/mindspore-1.6.0-cp37-cp37m-linux_x86_64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com

RUN echo 'umask 027' >> /etc/profile && \
    echo 'source /etc/profile' >> ~/.bashrc

RUN usermod -a -G HwHiAiUser hwMindX

RUN chmod 750 -R /home/hwMindX && \
    chmod 750 -R /home/HwHiAiUser && \
    chown hwMindX:hwMindX -R /home/hwMindX && \
    echo 'umask 027' >> /etc/profile && \
    echo 'source /etc/profile' >> ~/.bashrc

COPY label-studio/ /usr/local/lib/python3.7/dist-packages/label_studio/
COPY setup.sh /var/run/setup.sh
COPY  convert_json_file.py  /var/run/convert_json_file.py
COPY label-studio-ml-backend /var/run/label-studio-ml-backend


RUN cd /var/run/label-studio-ml-backend && pip install -U -e . && \
    pip install -r ./label_studio_ml/examples/yolov4tiny_detection/requirements.txt

RUN chmod +x /var/run/setup.sh && \
    chown hwMindX:hwMindX /var/run/setup.sh && \
    chmod +x /var/run/convert_json_file.py && \
    chown hwMindX:hwMindX /var/run/convert_json_file.py && \
    chown  hwMindX:hwMindX -R /var/run/label-studio-ml-backend


USER hwMindX